package com.aube.mis.controller;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.aube.mis.dto.ActorDTO;
import com.aube.mis.dto.PaginationResultDTO;
import com.aube.mis.dto.ShowDTO;
import com.aube.mis.dto.VideoThemeDTO;
import com.aube.mis.enums.ResourceType;
import com.aube.mis.service.ResourceService;
import com.aube.mis.service.ShowSettingService;
import com.aube.mis.service.ThemeService;
import com.aube.mis.vo.DataTableCriterias;

@Controller
@RequestMapping(value = "/theme")
public class ThemeController extends AbstractController {

	private static Logger log = LoggerFactory.getLogger(ThemeController.class);

	@Resource
	ResourceService resourceService;

	@Resource
	ThemeService themeService;

	@RequestMapping(value = "/video/list")
	public String videoList(HttpServletResponse response, ModelMap map, String sourceId, String isRelated, String callbackUrl, String relatedIds) throws Throwable {
		map.put("relatedIds", relatedIds);
		map.put("callbackUrl", callbackUrl);
		map.put("isRelated", isRelated);
		map.put("sourceId", sourceId);
		return "/theme/video/list";
	}
	@RequestMapping(value = "/video/list/data.ajax", produces = "text/plain;charset=UTF-8")
	@ResponseBody
	public String videoListData(ModelMap map) {
		List<VideoThemeDTO> videoThemeList = themeService.getVideoThemeList(getShowId());
		Map<String, Object> dataMap = new HashMap<String, Object>();
		dataMap.put("list", videoThemeList);
		return this.createSuccessResponse(dataMap);
	}

	@RequestMapping(value = "/video/preview")
	public String videoPreview(HttpServletResponse response, ModelMap map, String themeId) throws Throwable {
		VideoThemeDTO theme = themeService.getVideoThemeDetail(themeId);
		map.put("theme", theme);
		return "/theme/video/preview.page";
	}
	
}
